import formmatDate from '.././DdFormmatDate/index.ts';
import { export_json_to_excel } from './Export2Excel';
function formatJson(filterVal, jsonData) {
  return jsonData.map((v) => filterVal.map((j) => v[j]));
}
declare const require: any;
function export2Excel(
  header: any,
  value: any,
  data: any,
  exceltitle: string,
  isTime: boolean = true
) {
  require.ensure([], () => {
    // const { export_json_to_excel } = getExcel
    const TableData = formatJson(value, data);
    let fileTite = '';
    if (isTime) {
      fileTite =
        exceltitle + ' ' + formmatDate(new Date(), 'yyyy-MM-dd hh:mm:ss');
    } else {
      fileTite = exceltitle;
    }
    export_json_to_excel(header, TableData, fileTite);
  });
}

export default export2Excel;
